package fashionshop.gui_old;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

public class MainScreen {

	private JFrame frame;
	private MainScreen mainFrame;
	private JLabel titleLabel = new JLabel();
	public static JPanel mainPanel = new JPanel(new GridLayout(4, 1));
	public static JPanel menuPanel = new JPanel(new GridLayout(1, 3));
	public static JPanel detailPanel = new JPanel(new GridLayout(7, 7));
	public static JPanel tablePanel = new JPanel(new GridLayout(7, 7));
	

	/**
	 * Launch the application.
	 */
//	public static void main(String[] args) {
//		EventQueue.invokeLater(new Runnable() {
//			public void run() {
//				try {
////					MainScreen window = new MainScreen();
////					window.frame.setVisible(true);
////					window.mainFrame.setVisible(true);
//					fashionshop.gui.MainScreen aaa = new fashionshop.gui.MainScreen();
//					aaa.setVisible(true);
//					
//				} catch (Exception e) {
//					e.printStackTrace();
//				}
//			}
//		});
//	}

	/**
	 * Create the application.
	 * @throws Exception 
	 */
	public MainScreen() throws Exception {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 * @throws Exception 
	 */
	private void initialize() throws Exception {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setExtendedState(Frame.MAXIMIZED_BOTH);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JButton productButton = new JButton("Quản lý sản phẩm");
		JButton customerButton = new JButton("Quản lý khách hàng");
		JButton orderButton = new JButton("Quản lý đơn đặt hàng");
		JButton importButton = new JButton("Quản lý nhập kho");
		menuPanel.add(productButton);
		menuPanel.add(customerButton);
		menuPanel.add(orderButton);
		menuPanel.add(importButton);
		
		final ProductUI productUI = new ProductUI();
		final CustomerUI customerUI = new CustomerUI();
		final OrderUI orderUI = new OrderUI();
		final ImportUI importUI = new ImportUI();
		
		// Management Action
		productButton.addActionListener(new ActionListener() {
		    public void actionPerformed(ActionEvent ae) {
		    	titleLabel.setText("QUẢN LÝ SẢN PHẨM");
				productUI.loadAllProduct();
				productUI.loadProductDetail();
		    }
		});
		
		customerButton.addActionListener(new ActionListener() {
		    public void actionPerformed(ActionEvent ae) {
		    	titleLabel.setText("QUẢN LÝ KHÁCH HÀNG");
				customerUI.loadAllCustomer();
		    }
		});
		
		orderButton.addActionListener(new ActionListener() {
		    public void actionPerformed(ActionEvent ae) {
		    	titleLabel.setText("QUẢN LÝ ĐƠN ĐẶT HÀNG");
		    	orderUI.loadAllOrder();
		    }
		});
		
		importButton.addActionListener(new ActionListener() {
		    public void actionPerformed(ActionEvent ae) {
		    	titleLabel.setText("QUẢN LÝ NHẬP KHO");
		    	importUI.loadAllImport();
		    }
		});
		
		
		mainPanel.add(menuPanel);
		titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
		mainPanel.add(titleLabel, BorderLayout.CENTER);
		mainPanel.add(detailPanel);
		mainPanel.add(tablePanel);
		frame.add(mainPanel);
//		frame.add(menuPanel, BorderLayout.NORTH);
//		frame.add(titlelPanel, BorderLayout.CENTER);
//		frame.add(detailPanel, BorderLayout.CENTER);
//		frame.add(tablePanel, BorderLayout.SOUTH);
		frame.pack();
		frame.setVisible(true);
	}

}
